﻿@model LeadMaster.ViewModels.ViewModelDiary

@using (Ajax.BeginForm(new AjaxOptions
{
HttpMethod="Post",
UpdateTargetId = "diarylist"
}))
{
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Diary Entry for @Model.Company.Company</legend>
        @Html.HiddenFor(model => model.Diary.UserID)
        @Html.HiddenFor(model => model.Diary.LeadID)
        @Html.HiddenFor(model => model.Diary.CompanyID)
        @Html.HiddenFor(model => model.Diary.ContactType)
        @Html.HiddenFor(model => model.Diary.LeadID)

        <div class="editor-label">
            @Html.LabelFor(model => model.Diary.ContactID)
        </div>
        <div class="editor-field">
            @if (Model.Diary.ContactID == 0)
            {
                @Html.DropDownListFor(model => model.Diary.ContactID, new SelectList(Model.ContactsList, "Value", "Text", Model.Diary.ContactID), new { @class = "chzn-select", style = "width: 250px;" })
            }
            else
            {
                    @Html.DisplayNameFor(m => m.FullName)
            }
            @Html.ValidationMessageFor(model => model.Diary.ContactID)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Diary.ContactType)
        </div>
        <div class="editor-field">
             <table>
                <tr>
                <td><img src="~/Images/phone_icon.png" style="height:40px; width: 40px;" id="imgDiaryPhone" class="commsbutton" alt="Telephone"/></td>
                <td><img src="~/Images/email_icon.png"  style="height:40px; width: 40px;" id="imgDiaryEmail" class="commsbutton" alt="Email"/></td>
                <td><img src="~/Images/two_people_meeting.png"  style="height:40px; width: 40px;" id="imgDiaryMeeting" class="commsbutton" alt="Physical Meeting"/></td>
                <td><img src="~/Images/fax_icon2.jpg"  style="height:40px; width: 40px;" id="imgDiaryFax" class="commsbutton" alt="Fax"/></td>
                <td><img src="~/Images/Skype-icon.png"  style="height:40px; width: 40px;" id="imgDiarySkype" class="commsbutton" alt="Skype Meeting"/></td>
                <td><img src="~/Images/netmeeting.png"  style="height:40px; width: 40px;" id="imgDiaryNetMeeting" class="commsbutton" alt="Netmeeting"/></td></tr> 
            </table>
            @Html.ValidationMessageFor(model => model.Diary.ContactType)
        </div>
        <div class="spacer"></div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Diary.Notes)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Diary.Notes, new { @class = "reportbox" })
            @Html.ValidationMessageFor(model => model.Diary.Notes)
        </div>
        <div class="spacer"></div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Diary.Scheduled)
        </div>
        <div class="editor-field">
            <input type="text" id="DiaryHoldingDate" name="DiaryHoldingDate" value="@(Model.DiaryHoldingDate)" class="diaryDatePicker" style = "width: 80px;"/>
            @Html.TextBoxFor(model => model.DiaryHoldingTime, new { style = "width: 50px;" })
            @Html.ValidationMessageFor(model => model.Diary.Scheduled)
        </div>

        <div style="margin-top: 20px;float:right">
        <input type="submit" value="Save" class="bigsubmit" id="diarysubmit"/>
        </div> 
    </fieldset>
}


<script type="text/javascript">
    $(document).ready(function () {

        var currentDate = new Date();
        $("#imgDiaryMeeting").css("border-style", "solid");
        $("#Diary_ContactType").val("M");
        $("#DiaryHoldingTime").val(currentDate.getHours() + ":" + currentDate.getMinutes());
        jQuery(function ($) {
            $("#DiaryHoldingTime").mask("99:99");
        });

        $("#diarysubmit").click(function () 
        {
            $("#diarydialog").dialog('close');
            return true;
        });

        $(".commsbutton").click(function () {
            $("#imgDiaryPhone").css("border-style", this.id == "imgDiaryPhone" ? "solid" : "none");
            $("#imgDiaryEmail").css("border-style", this.id == "imgDiaryEmail" ? "solid" : "none");
            $("#imgDiaryMeeting").css("border-style", this.id == "imgDiaryMeeting" ? "solid" : "none");
            $("#imgDiaryFax").css("border-style", this.id == "imgDiaryFax" ? "solid" : "none");
            $("#imgDiarySkype").css("border-style", this.id == "imgDiarySkype" ? "solid" : "none");
            $("#imgDiaryNetMeeting").css("border-style", this.id == "imgDiaryNetMeeting" ? "solid" : "none");
            switch (this.id) {
                case "imgDiaryPhone":
                    $("#Diary_ContactType").val("T");
                    break;
                case "imgDiaryEmail":
                    $("#Diary_ContactType").val("E");
                    break;
                case "imgDiaryMeeting":
                    $("#Diary_ContactType").val("M");
                    break;
                case "imgDiaryFax":
                    $("#Diary_ContactType").val("F");
                    break;
                case "imgDiarySkype":
                    $("#Diary_ContactType").val("S");
                    break;
                case "imgDiaryNetMeeting":
                    $("#Diary_ContactType").val("N");
                    break;

                default:
            }
        });

        $(function () {
            $(".diaryDatePicker").datepicker({
                changeMonth: true,
                changeYear: true,
                regional: 'en-GB',
                dateFormat: 'dd/mm/yy'
            });
        });

    });
</script>

